﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Com.CMS263.PO;
using System.Collections.Generic;
using Com.CMS263.BLL;
using Com.CMS263.Util;

namespace Com.CMS263.Web.manage.ManageAttrType
{
    public partial class AddAttributeType : System.Web.UI.Page
    {
        AttributeTypeBLL bll = new AttributeTypeBLL();
        protected void Page_Load(object sender, EventArgs e)
        {


            if (!this.IsPostBack)
            {
                this.BindType();
            }

        }
        public void BindType()
        {
            this.rptList.DataSource = bll.GetAllAttributeType();
            this.rptList.DataBind();
        }
        public void del(Object sender, CommandEventArgs args)
        {

        }

        protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int id = Convert.ToInt32(e.CommandArgument);
            bll.Delete(id);
            this.BindType();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
           
            AttributeType at = new AttributeType();

            at.typeName = Request["txtTypeName"].Trim();
            string outapp = Request["selOutType"];
            if (outapp.Equals("0"))
            { outapp = Request["txtOutApp"]; }
            else if (outapp.Equals("-1"))
            {
                outapp = "ManagerCategory/CategoryList.aspx?typeId=" + Request["txtOutApp"].Trim();
            }
            
                at.outApp = StringUtil.checkStr(outapp.Trim());
            
            AttributeTypeBLL bll = new AttributeTypeBLL();
            bll.Add(at);
            string menu = new ArtTypeBLL().GetTypeTree();
            FileUtil.WriteToFile(Server.MapPath("/manage/menutext/menu.txt"), menu);
            StringUtil.Alert("添加成功", "AddAttributeType.aspx");

        }
    }

}
